package com.itboye.mengwu.data.repository;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;
import com.itboye.mengwu.data.interfaces.IBiaoQian;
import com.itboye.mengwu.data.model.BabyBean;
import com.itboye.mengwu.data.model.BiaoQianModel;

public class BiaoQianRepository extends BaseNetRepository implements
		IBiaoQian<BiaoQianModel> {
	String api = "100";
	public static final String QUERYBIAOQIAN = "BY_Tag_finds";
	public static final String ADDBIAOQIAN = "BY_Tag_addAll";

	public BiaoQianRepository(ICompleteListener listener) {
		super(listener);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(BiaoQianModel model) {
		// TODO Auto-generated method stub
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", model.getUid());
		params.put("tag_name", model.getTag_name());
		params.put("tid", model.getTid());

		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(ADDBIAOQIAN, apiVer, params,
						String.class)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void delete(BiaoQianModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(BiaoQianModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(BiaoQianModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<BiaoQianModel> queryYouHuiQuan(BiaoQianModel model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void QueryBiaoQian(String uid, String sort, String number) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<ArrayList<BiaoQianModel>>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("sort", sort);
		params.put("number", number);

		(new Builder<ArrayList<BiaoQianModel>>())
				.setTypeVerParamsAndReturnClass(QUERYBIAOQIAN, apiVer, params,
						type)
				.requestListener(
						new BaseSuccessReqListener<ArrayList<BiaoQianModel>>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

}
